package hapi.receive;

import jade.core.Agent;
import jade.core.behaviours.Behaviour;
import jade.core.behaviours.TickerBehaviour;
import jade.lang.acl.ACLMessage;

public class RedirectorBehaviour extends Behaviour{
	
	private Agent agent;

	public RedirectorBehaviour(Agent a){
		this.agent = a;
	}

	@Override
	public void action() {
		//System.out.println("[Redirector Behaviour]:");
		ACLMessage msg = agent.receive();
		if (msg!=null){
			agent.addBehaviour(new ReceiveBehaviour(agent, msg));
			//System.out.println("Success!");
		}
		else{
			//System.out.println("Fail!");
			block();
		}
	}

	@Override
	public boolean done() {
		return false;
	}
}
